#pragma once

#include "Wrap.h"

namespace System
{
class CMObject {
protected:

#ifdef _MANAGED
  gcroot<Object^> m_handle;
#else
  intptr_t m_handle;
#endif

public:

#ifdef _MANAGED
	// visible to managed clients only: anything that deals with __gc objects
	CMObject(Object^ o) : m_handle(o) {	}
	Object^ ThisObject() const { return (Object^)m_handle; }
	Object^ operator->() const { return ThisObject(); }
#endif

	// visible to all clients
	WREXPORT CMObject();
	WREXPORT CMObject(const CMObject& o);
	WREXPORT CMObject& operator=(const CMObject& r);

	WREXPORT BOOL operator==(const CMObject& r) const;
	WREXPORT BOOL operator!=(const CMObject& r) const { return ! operator==(r); }
	WREXPORT CString ToString() const;
	WREXPORT CString TypeName() const;
	WREXPORT bool IsNull() const;
	WREXPORT void SetNull();
  WREXPORT bool IsDerivedFrom(const CMObject& object) const;
};
}
